import {defineStore} from "pinia";
import {getHomeDataApi} from '~/service/home'

export const useHomeStore = defineStore('useHomeStore', {
  state:() => {
    return {
      navBars: [],
      banners: [],
      category: [],
    }
  },
  actions:{
    //服务端发送请求存到pinia,同步数据到客户端pinia,客户端获取数据
    async getHomeData(){
      const { data } = await getHomeDataApi();
      this.navBars = data.value?.data.navbars ?? [];
      this.banners = data.value?.data.banners ?? [];
      this.category = data.value?.data.categorys ?? [];
    }
  },
  getters:{

  }
})
